<!--
  @author yangjiangming
  @date 2018/11/26 10:00
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>工单改派</title>
    <th:block th:replace="common/common :: jscss"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <!-- 精准查询 -->
                    <li data-type="-1">
                        <span th:text="精准查询"></span>
                        <span id="precise-count"></span>
                    </li>
                </ul>

                <div class="layui-tab-content" id="tab-content" style="padding: 15px 0;">
                    <!-- 精准查询表单 -->
                    <div class="layui-tab-item layui-show">
                        <form class="search-form" method="post">
                            <div class="layui-form layui-margin-t" th:include="redistribute/_query :: query "></div>
                        </form>
                    </div>
                </div>
            </div>

            <!-- 数据表格 -->
            <table th:replace="redistribute/_table :: redistribute-table"></table>
        </div>

    </div>
</div>

<!-- 公共变量 -->
<th:block th:replace="common/listQueryTmpl :: commonVariable"/>

<script type="text/javascript" th:inline="javascript">
    var templates = {
        formatWarning: function (data) {
            var warningBadgeFactory = function (warning, type, text, bgColor) {
                if (!warning || warning == 1) {
                    return '';
                }

                var classArr = [
                    'layui-badge',
                    'work-warning',
                    `work-warning-${type}`,
                ].filter(function (item) {
                    return item;
                });

                let css = '';
                if (bgColor) {
                    css = 'background: ' + bgColor + ';';
                }
                return (
                    `<span class="${classArr.join(' ')}" style="${css}">
                                <span class="work-warning-text">
                                    ${text}
                                </span>
                            </span>`
                );
            };

            var htmlStr = '';
            if (data.spuriousStatus == 2
                || data.auditWarningStatus == 2
                || data.auditTimeoutStatus == 2
                || data.helpTimeoutStatus == 2
            ) {

                htmlStr = `<span class="warning-wrapper">
                                <span class="warning">
                                    <!-- 虚假改派 -->
                                    ${warningBadgeFactory(data.spuriousStatus, 'spurious-status', '虚假')}
                                    <!-- 审核预警-->
                                    ${warningBadgeFactory(data.auditTimeoutStatus == 1 ? data.auditWarningStatus : null, 'audit-warning-status', '预警', '#7f7f7f')}
                                    <!-- 审核超时 -->
                                    ${warningBadgeFactory(data.auditTimeoutStatus, 'audit-timeout-status', '超时', '#f59a23')}
                                    <!-- 转单超时 -->
                                    ${warningBadgeFactory(data.helpTimeoutStatus, 'help-timeout-status', '转单超时', '#f59a23')}
                                </span>

                                <span class="warning-content">
                                    <!-- 虚假改派 -->
                                    ${warningBadgeFactory(data.spuriousStatus, 'spurious-status', '虚假改派')}
                                    <!-- 审核预警-->
                                    ${warningBadgeFactory(data.auditTimeoutStatus == 1 ? data.auditWarningStatus : null, 'audit-warning-status', '审核预警', '#7f7f7f')}
                                    <!-- 审核超时 -->
                                    ${warningBadgeFactory(data.auditTimeoutStatus, 'audit-timeout-status', '审核超时', '#f59a23')}
                                    <!-- 转单超时 -->
                                    ${warningBadgeFactory(data.helpTimeoutStatus, 'help-timeout-status', '转单求助超时', '#f59a23')}
                                </span>
                            </span>`;
            }

            return htmlStr;
        },
            resultStatusFormatterFactory: function (keyword) {
                return function (data) {
                    var className;
                    var calssStatus;
                    var text;
                    var htmlStr = '';

                    if (keyword === 'status') {
                        className = 'zmn-work-status-' + data.status;
                        text = data.statusName;
                        calssStatus = 'order-status';
                        if (data.multipleVisitStatusName) {
                            htmlStr += '<span>' +
                                '<span class="layui-badge ' + className + ' ' + calssStatus + '">' + text + '</span>' +
                                '<span class="visit-content">主状态：' + text + '<br>子状态：' + data.multipleVisitStatusName + '</span>' +
                                '</span>';
                        } else {
                            htmlStr += '<span class="layui-badge ' + className + '">' + text + '</span>';
                        }

                        return htmlStr;
                    }
                }
            }
        }
</script>

<script type="text/javascript" th:inline="javascript">
    var plat = platMark.ZMN;
    let staffId = [[${staffId}]];
    let orderId = '[[${orderId}]]';
    var tableName = 'redistribute';
    var defaultBizType = BIZ_TYPE.C;

    // 改派状态List
    let redistributeAuditStatusList = [[${T(com.zmn.oms.common.enums.RedistributeStatusEnum).getRedistributeStatusList()}]];

    // 改派审核状态List
    let auditStatusList = [[${T(com.zmn.oms.common.enums.RedistributeAuditStatusEnum).getRedistributeAuditStatusList()}]];

    // 改派求助状态List
    let helpStatusList = [[${T(com.zmn.oms.common.enums.RedistributeHelpStatusEnum).getRedistributeHelpStatusList()}]];

    var defaultToolbar = ['filter', 'print'];
    var exportPermit = [[${exportPermit}]];
    if(exportPermit){
        defaultToolbar.push({
            title: '导出',
            layEvent: 'exports',
            icon: 'layui-icon-export'
        });
    }

    layui.config({
        version: 20221013001
    }).extend({
        oms_redistribute_list: 'redistribute/zmn.oms.redistribute.list'
    }).use(['index', 'oms_redistribute_list']);
</script>
</body>
</html>